#include "Sock.hpp"

int main(int argc, char* argv[])
{
  int listen_sockfd = Sock::Socket();
  Sock::Bind(listen_sockfd, atoi(argv[1]));
  Sock::Listen(listen_sockfd);
  while(true){
    int sockfd = Sock::Accept(listen_sockfd);
    int opt = 1;
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
    char buffer[1024];
    while(true){
      ssize_t size = read(sockfd, buffer, sizeof(buffer) - 1);
      if(size == 0){
        break;
      }
    }
    close(sockfd);
  }

  return 0;
}
